package com.huidu.bitrade.controller.common;

import com.aliyun.oss.ClientConfiguration;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.common.auth.CredentialsProvider;
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
import com.aliyun.oss.model.PutObjectRequest;
import com.aliyun.oss.model.PutObjectResult;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.auth.sts.AssumeRoleRequest;
import com.aliyuncs.auth.sts.AssumeRoleResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.net.URL;
import java.util.Date;

@Slf4j
public class UploadControllerTestOss {


    @Test
    public void uploadOssImage1() throws FileNotFoundException {
        OSSClient ossClient = new OSSClient("oss-cn-hongkong.aliyuncs.com",
                "LTAI5tMiQZ1tJrC1WsE7tgCc",
                "tQ0a45EmsXxrN695vo6iByl6Jgfpxj");
        String ossPath = "test.jpg";
        File file = new File("C:\\Users\\a\\Desktop\\微信图片_20230616090558.jpg");
        PutObjectResult putObjectResult = ossClient.putObject("huidu-static", ossPath, new FileInputStream(file));
        String string = putObjectResult.toString();
        System.out.println(string);
    }

}
